//
//  SearchTextField.m
//  Order
//
//  Created by 全家科技 on 16/4/11.
//  Copyright © 2016年 全家科技. All rights reserved.
//

#import "SearchTextField.h"
//
//#define kScreenHeight [[UIScreen mainScreen] bounds].size.height
//#define kScreenWidth [[UIScreen mainScreen] bounds].size.width
@implementation SearchTextField

- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
    }
    [self createUI];
    return self;
}
- (void)createUI
{
    self.backgroundColor = [UIColor whiteColor];
    self.borderStyle = UITextBorderStyleRoundedRect;
    [self resignFirstResponder];
    
    UIImageView *searchImageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"search1"]];
    searchImageView.frame = CGRectMake(0, 0, 36,36);
    searchImageView.contentMode = UIViewContentModeCenter;
    //设置图片一直显示
    self.leftViewMode = UITextFieldViewModeAlways;
    self.leftView = searchImageView;
    self.clearButtonMode = UITextFieldViewModeNever;
}

- (CGRect)textRectForBounds:(CGRect)bounds
{
    return CGRectMake(32, 33, kScreenWidth-50-32, 36);
}
- (CGRect)placeholderRectForBounds:(CGRect)bounds
{
    return CGRectMake(32, 33, kScreenWidth-50-32, 36);
}

@end
